import service from "@/utils/request";
import { classifyInfo, ApiResponse, ResourceData, classifyList } from "./type";
import { AxiosPromise } from "axios";
const { resourceService } = service;

/**
 * 一级分类接口方法
 */

export function getResourceOne(): AxiosPromise<ResourceData> {
  return resourceService({
    url: "/resource/resourceType/getLevel1",
    method: "get",
  });
}

/**
 * 二级分类接口方法
 */

export function getResourceTwo(id: number): AxiosPromise<any> {
  return resourceService({
    url: "/resource/resourceType/getLevel2/" + id,
    method: "get",
  });
}

/**
 * 三级分类接口方法
 */

export function getResourceThree(id: number): AxiosPromise<any> {
  return resourceService({
    url: "/resource/resourceType/getLevel2/" + id,
    method: "get",
  });
}

//获取资源列表
export function getResourceList(): AxiosPromise<any> {
  return resourceService({
    url: "/resource/resourceType/getAll",
    method: "get",
  });
}

/**
 * 添加资源
 */

export function addResource(data: classifyInfo): AxiosPromise<any> {
  return resourceService({
    url: "/resource/resourceType/add",
    method: "post",
    data: data,
  });
}

/**
 * 删除资源
 */

export function deleteResource(id: number): AxiosPromise<any> {
  return resourceService({
    url: "/resource/resourceType/del/" + id,
    method: "delete",
  });
}

/**
 * 修改资源
 */

export function editResource(data: classifyInfo): AxiosPromise<any> {
  return resourceService({
    url: "/resource/resourceType/update",
    method: "put",
    data: data,
  });
}

/**
 * 博客分类
 */

//获取分类数据
export function getListBlog(): AxiosPromise<ResourceData> {
  return resourceService({
    url: "resource/category/selectAll",
    method: "get",
  });
}

//删除博客分类数据

export function deleteblog(id: number): AxiosPromise<any> {
  return resourceService({
    url: "/resource/category/deleteCategory/" + id,
    method: "delete",
  });
}

//修改博客分类数据
export function editblot(data: classifyList): AxiosPromise<any> {
  return resourceService({
    url: "/resource/category/updateCategory",
    method: "put",
    data: data,
  });
}

//添加博客分类数据

export function addblog(data: classifyList): AxiosPromise<any> {
  return resourceService({
    url: "/resource/category/addCategory",
    method: "post",
    data: data,
  });
}
